<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\Config;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class ConfigController extends Controller
{
    /**
     * 获取配置信息
     */
    public function index(Request $request)
    {
//        $params = $request->only('name','keys');
        $config = Config::getValue($request->input('keys',[]));
        return apiResponse(data: $config);
    }

    /**
     * 保存配置
     */
    public function save(Request $request){
        $params = $request->all();
        foreach ($params as $key => $value) {
            Config::where('key',$key)->update(['value'=>$value]);
        }
        return apiResponse(msg:'配置保存成功');
    }

}
